<?php 
require_once('config/config.php');
require_once('checked.php'); //判断是否登录   



//判断是不是post请求
if($_POST){
  // 获取表单提交的值
  $name = isset($_POST['name']) ? trim($_POST['name']) :'';
  // 判断添加的职务是否存在
  $sql = "SELECT * FROM {$pre_}job WHERE name = '$name'";
  $jobname = select($sql);
  if($jobname){
    notice("该职务已经存在!");
    exit;
  }
  // 封装数据
  $data = [
    "name"=> $name,
  ];
  //给表名
  $table = 'job';

  //书写添加的方法
  $i =  insert($table,$data);
  if($i){
    notice('添加职务信息成功!','JobList.php');
    exit;
  }else{
    notice('添加职务信息失败!');
    exit;
  }

}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <?php require_once('meta.php') ?>
  </head>
  
  <body>
    <!-- 头部 -->
    <?php require_once('header.php') ?>
    
    <div class="sidebar-nav">
        <a href="#dashboard-menu" class="nav-header" data-toggle="collapse"><i class="icon-dashboard"></i>控制面板</a>
        <ul id="dashboard-menu" class="nav nav-list collapse in">
            <li><a href="index.php">首页</a></li>
            <li><a href="list.php">职务管理</a></li>
        </ul>
    </div>

    <div class="content">
        <div class="header">
            <h1 class="page-title">职务添加</h1>
        </div>
        <ul class="breadcrumb">
            <li><a href="index.php">Home</a> <span class="divider">/</span></li>
            <li class="active">Index</li>
        </ul>

        <div class="container-fluid">
            <div class="row-fluid">
                    
                <div class="btn-toolbar">
                    <button class="btn btn-primary" onClick="location='JobList.php'"><i class="icon-list"></i> 职务列表</button>
                  <div class="btn-group">
                  </div>
                </div>

                <div class="well">
                    <div id="myTabContent" class="tab-content">
                      <div class="tab-pane active in" id="home">
                        <form method="post" enctype="multipart/form-data">  
                            <label>职务名称</label>
                            <input type="text" name="name" id="name" value="" placeholder="请输入职务名称" class="input-xxlarge" required>
                            <label></label>
                            <input class="btn btn-primary" type="submit" value="提交" />
                        </form>
                      </div>
                  </div>
                </div>

                <div class="modal small hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h3 id="myModalLabel">Delete Confirmation</h3>
                  </div>
                  <div class="modal-body">
                    
                    <p class="error-text"><i class="icon-warning-sign modal-icon"></i>Are you sure you want to delete the user?</p>
                  </div>
                  <div class="modal-footer">
                    <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
                    <button class="btn btn-danger" data-dismiss="modal">Delete</button>
                  </div>
                </div>
                
                <footer>
                    <hr>
                    <p>&copy; 2017 <a href="#" target="_blank">copyright</a></p>
                </footer>
                    
            </div>
        </div>
    </div>
  </body>
</html>
<script>
</script>